﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Yuekao.API.Write.Command;
using Yuekao.Domain.API;

namespace Yuekao.API.Write.Controllers
{
    /// <summary>
    /// 基础数据 -API -写
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManagementController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator">中介者</param>
        public ManagementController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 流程设计新增
        /// </summary>
        /// <param name="command">流程设计实体</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public Task<APIResult<int>> DefinitionAdd(DefinitionAddCommand command)
        {
            return mediator.Send(command);
        }
        /// <summary>
        /// 流程发起
        /// </summary>
        /// <param name="command">流程实例实体</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public Task<APIResult<string>> InstanceAdd(InstanceAddCommand command)
        {
            return mediator.Send(command);
        }
        /// <summary>
        /// 审批
        /// </summary>
        /// <param name="command">审批内容</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public Task<APIResult<int>> AuditAdd(AuditAddCommand command)
        {
            return mediator.Send(command);
        }
        /// <summary>
        /// 添加表单
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public Task<APIResult<int>> FormDataAdd(FormDataAddCommand command)
        {
            return mediator.Send(command);
        }
    }
}
